<template>
	<view>
		<back :showBackText="false" customClass="bg-gradual-blue text-white" :title="title"></back>
		<view v-if="isLoad">
			<block v-for="(course, idx) in listData" :key="idx">
				<view @tap="openTap" class="course-layout" :data-index="idx"
					style="border-bottom-left-radius: 0rpx; border-bottom-right-radius: 0rpx; margin-top: 0">
					<image class="group-state" :src="!course.is_open ? closeIcon : openIcon"></image>
					<view class="course-name text-cut">{{ course.name }}</view>
				</view>
				<view @tap="courseTap" class="paper-layout" :data-course="item" :style="
                        'border-left: ' +
                        borderWidth +
                        'rpx solid #F6F6F6; border-right: ' +
                        borderWidth +
                        'rpx solid #F6F6F6; border-bottom: ' +
                        borderWidth +
                        'rpx solid #F6F6F6;margin-bottom:20rpx'
                    " v-if="!course.is_open" v-for="(item, index) in course.section" :key="index">
					<view class="red-circle"></view>

					<view class="paper-name text-cut">{{ item.name }}</view>

					<view class="item-count">{{ item.count }}题</view>

					<image src="/static/img/ic_count.png"></image>
				</view>
				<view class="paper-layout" :style="
                        'border-left: ' +
                        borderWidth +
                        'rpx solid #F6F6F6; border-right: ' +
                        borderWidth +
                        'rpx solid #F6F6F6; border-bottom: ' +
                        borderWidth +
                        'rpx solid #F6F6F6;'
                    " v-if="!course.is_open && !course.section.length">
					<view class="paper-name" style="text-align: center; margin-left: 0">本章节暂无题目</view>
				</view>
			</block>

			<empty v-if="listData.length == 0" info="暂无题目"></empty>

			<view class="cu-bar bg-white margin radius" style="margin: 0;">
				<view class="action">
					<text class="cuIcon-locationfill text-blue"></text>课程导航
				</view>
				<view class="action" style="margin-right: 0;">
					<view class="padding flex flex-wrap justify-between align-center bg-white">
						<button class="cu-btn bg-green shadow" @tap="onCourseTap" style="padding: 10rpx;">
							<text class="cuIcon-discoverfill text-blue"></text>
							<text style="margin-left: 4rpx;">课程详情</text>
						</button>
						<button v-if="!appIsAudit && listData.length > 0" class="cu-btn bg-red shadow" @tap="onBuyTap"
							style="padding: 10rpx;margin-left: 20rpx;">
							<text class="cuIcon-goodsfill text-blue"></text>
							<text style="margin-left: 4rpx;">购买题库</text>
						</button>
					</view>
				</view>
			</view>
			<adbanner v-if="listData.length > 0"></adbanner>
			<adfootbanner v-if="listData.length == 0"></adfootbanner>
		</view>
	</view>
</template>
<style src="./chapter.css"></style>
<script src="./chapter.js"></script>